<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>真人认证</title>
		<script src="./js/CameraUtils.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
		<style type="text/css">
			body {
				margin: 0;
				padding: 0;
			}

			.notic-pop {
				position: fixed;
				bottom: 0;
				background: #000000;
				opacity: 0.7;
				height: 250px;
				width: 100%;
				display: flex;
				flex-direction: column;
				align-items: center;
			}

			.notic-tilte {
				padding: 15px 0;
				font-size: 24px;
				font-weight: 400;
				color: #ffffff;
			}

			.v-code {
				height: 60px;
				line-height: 60px;
				color: #ffffff;
				font-size: 40px;
			}

			.paly-group {
				position: absolute;
				padding: 20px 0;
				bottom: 0;
			}

			.button-play {
				border-radius: 50%;
				width: 50px;
				height: 50px;
				background: linear-gradient(291deg, #ff9509 0%, #fe2042 100%);
			}

			.outer-ring-one {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				border-radius: 50%;
				width: 60px;
				height: 60px;
				background-color: #ffffff;
			}

			.outer-ring-two {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				border-radius: 50%;
				width: 61px;
				height: 61px;
				background: linear-gradient(291deg, #ff9509 0%, #fe2042 100%);
			}

			.outer-ring-three {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				border-radius: 50%;
				width: 71px;
				height: 71px;
				background: #ffffff;
			}

			.palyed .outer-ring-two {
				background: #999999;
			}

			.palyed .button-play {
				background: #999999;
			}
		</style>
	</head>

	<body>

		<video class="video-paly" muted="true"></video>
		<div class="notic-pop">
			<div class="notic-tilte">使用普通话读出下列数字</div>
			<div class="v-code">957500</div>
			<div class="paly-group">
				<div class="outer-ring-three">
					<div class="outer-ring-two">
						<div class="outer-ring-one">
							<div class="button-play"></div>
						</div>
					</div>
				</div>
			</div>
		</div>

		</script>
		<script type="text/javascript">
			let video = {
				videoLongTime: 12000,
				palyFlag: false,
				data: null
			};

			let query = window.location.search.substring(1).split('=');
			var codeDom = document.querySelector('.v-code');
			codeDom.innerText = query[1];

			document.addEventListener('UniAppJSBridgeReady', function() {
				var videoDom = document.querySelector('.video-paly');
				CameraUtils.init(videoDom);

				document.querySelector('.paly-group').addEventListener('click', function(evt) {
					var playDom = document.querySelector('.paly-group');
					playDom.classList.toggle('palyed');
					if (!video.palyFlag) {
						CameraUtils.start(video.videoLongTime, dataBase64 => {
							video.palyFlag = true;
							video.data = dataBase64;
							uni.postMessage({
								data: {
									videoData:video.data
								}
							});
						});
					}
				});
			});
		</script>
	</body>
</html>
